import api from './index'

export const sqlWorkOrderAPI = {
  // 工单管理
  getWorkOrders(params) {
    return api.get('/sql/work-orders/', { params })
  },

  getWorkOrder(id) {
    return api.get(`/sql/work-orders/${id}/`)
  },

  createWorkOrder(data) {
    return api.post('/sql/work-orders/', data)
  },

  updateWorkOrder(id, data) {
    return api.put(`/sql/work-orders/${id}/`, data)
  },

  deleteWorkOrder(id) {
    return api.delete(`/sql/work-orders/${id}/`)
  },

  // 审核工单
  reviewWorkOrder(id, data) {
    return api.post(`/sql/work-orders/${id}/review/`, data)
  },

  // 执行工单
  executeWorkOrder(id, data = {}) {
    return api.post(`/sql/work-orders/${id}/execute/`, data)
  },

  // 撤回工单
  withdrawWorkOrder(id) {
    return api.post(`/sql/work-orders/${id}/withdraw/`)
  },

  // 获取管理员用户列表
  getAdminUsers() {
    return api.get('/sql/admin-users/')
  },

  // 我的工单
  getMyWorkOrders(params) {
    return api.get('/sql/work-orders/', { 
      params: {
        ...params,
        my_orders: true
      }
    })
  }
}
